/*
 * Copyright 2001 Alexander Boverman and the original authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _WT_TABLE_UTIL_H
#define _WT_TABLE_UTIL_H

#include <tcl.h>

Tcl_Obj *WtTableToList(Tcl_Obj *table, int takeFirstValue, Tcl_Interp *interp);
int WtTableToArray(Tcl_Interp *interp, Tcl_Obj *table, Tcl_Obj *arrName,
  int takeFirstValue);
int WtTableHasStr(Tcl_Obj *tbl, const char *key);
void WtTableSetStrToStr(Tcl_Obj *tbl, const char *key, const char *val);
void WtTableSetStrToInt(Tcl_Obj *tbl, const char *key, int val);
void WtTableSetStrToBool(Tcl_Obj *tbl, const char *key, int val);
void WtTableSetStrToLong(Tcl_Obj *tbl, const char *key, long val);
void WtTableSetStrToDouble(Tcl_Obj *tbl, const char *key, double val);
void WtTableSetStrToObj(Tcl_Obj *tbl, const char *key, Tcl_Obj *val);
void WtTableSetIntToObj(Tcl_Obj *tbl, int key, Tcl_Obj *val);
int WtTableAppendStrToList(Tcl_Obj *tbl, const char *key, const char *val,
  Tcl_Interp *interp);
int WtTableAppendObjToList(Tcl_Obj *tbl, const char *key, Tcl_Obj *valObj,
  Tcl_Interp *interp);
char *WtTableGetStrFromStr(Tcl_Obj *tbl, const char *key, char *fallback);
int WtTableGetIntFromStr(Tcl_Obj *tbl, const char *key, int fallback);
int WtTableGetBoolFromStr(Tcl_Obj *tbl, const char *key, int fallback);
Tcl_Obj *WtTableGetObjFromStr(Tcl_Obj *tbl, const char *key, Tcl_Obj *fallback);
Tcl_Obj *WtTableGetObjFromInt(Tcl_Obj *tbl, int key, Tcl_Obj *fallback);
void WtTableRemoveStr(Tcl_Obj *tbl, const char *key);
int WtOwnTable(Tcl_Obj **objPtr, Tcl_Interp *interp);
int WtOwnCaselessTable(Tcl_Obj **objPtr, Tcl_Interp *interp);
int WtOwnTableObj(Tcl_Obj **objPtr, Tcl_ObjType *type, Tcl_Interp *interp);
int WtImportTableVars(Tcl_Obj *tbl, Tcl_Interp *interp);

#endif /* ! _WT_TABLE_UTIL_H */
